package cn.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/failServlet")
public class failServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("fail跳转成功");
        response.setContentType("text/html;charset=utf-8");  // tomcat默认的是拉丁文解码器，是无法对中文进行解码对，所以我们需要设置编码类型，并告诉客户端，让客户端也采用相同对解码器
        // 当编码器和解码器的码表不同时 就会出现乱码
        response.getWriter().write("登陆失败");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
